using AjaxControlToolkit;
using ASP;
using IPMS.AccessAuth;
using IPMS.BLL;
using System;
using System.Configuration;
using System.Globalization;
using System.IO;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using Resources;

public partial class ProjectDocumentUploadInquiry : Page, IRequiresSessionState
{
    protected void btnExport_Click(object sender, EventArgs e)
    {
        base.Response.Clear();
        base.Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
        base.Response.Charset = "";
        base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        base.Response.ContentType = "application/vnd.xls";
        StringWriter stringWrite = new StringWriter();
        HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
        this.gvResults.RenderControl(htmlWrite);
        base.Response.Write(stringWrite.ToString());
        base.Response.End();
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        doSearch();
    }

    protected override void InitializeCulture()
    {
        string sCulture = ConfigurationManager.AppSettings["DefaultCulture"].ToString();
        try
        {
            sCulture = this.Session["Culture"].ToString();
        }
        catch (NullReferenceException)
        {
        }
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(sCulture);
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(sCulture);
        base.InitializeCulture();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ((Label)this.Master.FindControl("lblMstTitle")).Text = "| " + ISitemap.Search.ToString() + " | " + ISitemap.ProjectDocumentUploadInquiry.ToString();

        }

        Auth canView = new Auth(this.Session["UserId"].ToString(), string.Empty, "ProjectDocumentUploadInquiry ");
        if (!canView.CanView())
        {
            base.Response.Redirect("ErrorPage/NotAllowed.aspx");
        }
        else
        {
            StringBuilder sb = new StringBuilder();
            this.setTextBox();
            doSearch();
        }
    }

    protected void setTextBox()
    {
    }

    public override void VerifyRenderingInServerForm(Control control)
    {
    }
    private void doSearch()
    {
        this.ODSProjectDocumentUpload.SelectMethod = "GetSearchResult";
        this.ODSProjectDocumentUpload.SelectParameters["StartingBatchID"].DefaultValue = this.txtStartingBatchID.Text.ToString();
        this.ODSProjectDocumentUpload.SelectParameters["EndingBatchID"].DefaultValue = this.txtEndingBatchID.Text.ToString();
        this.ODSProjectDocumentUpload.SelectParameters["StartingTransDate"].DefaultValue = IPDataFormat.ConvertDateFormat(this.txtStartingTransDate.Text.ToString(), 1);
        this.ODSProjectDocumentUpload.SelectParameters["EndingTransDate"].DefaultValue = IPDataFormat.ConvertDateFormat(this.txtEndingTransDate.Text.ToString(), 1);
        this.ODSProjectDocumentUpload.SelectParameters["Remark"].DefaultValue = this.txtRemark.Text.ToString();
        this.ODSProjectDocumentUpload.Select();
    }
}
